<template>
  <div>
    <van-index-bar>
      <div v-for="v in carList" :key="v.word">
        <van-index-anchor :index="v.word" />
        <van-cell
          v-for="item in v.children"
          :key="item.id"
          :title="item.title"
					@click="toDetail(item.id)"
        />
      </div>
    </van-index-bar>
  </div>
</template>

<script>
import { mapState, mapActions } from "vuex";
export default {
  name: "selectCar",
  computed: {
    ...mapState(["carList"]),
  },
  methods: {
    ...mapActions(["fetchCarList"]),
		toDetail(id) {
			this.$router.push({
				name: 'detail',
				params: {
					id
				}
			})
		}
  },
  mounted() {
    this.fetchCarList();
  },
};
</script>